import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 666
 * Date: 2023-04-08
 * Time: 18:26
 */
public class test0 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        char a =scanner.next().charAt(0);
        int arr=0;
        if(a>=65  &&  a<= 90){
            for (int i = 0; i < str.length(); i++) {
                if(a == str .charAt(i)  || a==str.charAt(i)+32){
                  arr++;
                }
            }
            System.out.println(arr);

        }else if( a>=97  &&  a<=122){
            for (int i = 0; i < str.length(); i++) {
                if(a == str .charAt(i)  || a==str.charAt(i)-32){
                    arr++;
                }
            }
            System.out.println(arr);

        }else {
            for (int i = 0; i < str.length(); i++) {
                if(a==str.charAt(i)){
                    arr++;
                }
            }
            System.out.println(arr);

        }
    }
}
